package com.sg.business.commons.elementdisplay;

import org.bson.types.ObjectId;

import com.mobnut.db.model.ModelService;
import com.sg.business.model.Deliverable;
import com.sg.business.model.Document;
import com.sg.widgets.viewer.IElementDisplayAdapter;

public class DocForDeliAdapter implements IElementDisplayAdapter {

	@Override
	public Object getAdapter(Object element) {
		if (element instanceof Deliverable) {
			ObjectId documentId = ((Deliverable) element).getDocumentId();
			if (documentId != null) {
				return ModelService.createModelObject(Document.class,
						documentId);
			}
		}
		return ModelService.createModelObject(Document.class);
	}

}
